Brian
Brian

Reputation: 31

Tags That Will Operate As Multiple Tags

I had a very hard time trying to word what I wish to know how to do, nor could I locate any post or website from Google that had my answer probably due to not being able to word this correctly, but I will explain in fullest detail.

<br />
<hr />
<br />

Break, horizontal, break is my way of separating parts of the post from another. How can I group the three into one simple tag that can replace the three, thus saving me time and hassle .

It would be also helpful to know if there are ways to define tag groupings with more than just empty tags like a tag identified by the string title1 would be a tag containing all the format, text, and all sub-elements of the template that was coded somewhere else.

If this question has already been posted then I am sorry. Thanks!

Upvotes: 0

Views: 121

Answers (3)

David Underwood
David Underwood

Reputation: 4966

Whilst this specific problem can be solved with a little bit of CSS, it sounds like you need a layout or templating engine of some sort in the long run. I'm a rubyist by trade so my go-to solution for doing this is Jekyll.

What Jekyll does is generate static html files from layouts and content that you write. You can abstract a lot of the repetitive layout markup into separate files and then just reference them when you need them.

The following guide is a good place to get started: http://net.tutsplus.com/tutorials/other/building-static-sites-with-jekyll/

If you're already working with another framework then do some reading around it first to see if there's something there you can use. If you're just writing straight-up HTML/CSS though, then definitely give Jekyll a try.

Upvotes: 1

Konrad Rudolph
Konrad Rudolph

Reputation: 545588

Neither <br> nor the proposed alternative <hr> are particularly well-suited here.

You need to learn about CSS. All you need to do is apply appropriate styles (i.e. a margin) to the elements that wrap your posts.

<div class="post">
    <h1>Post #1</h1>
    <p>something</p>
</div>

<div class="post">
    <h1>Post #2</h1>
    <p>something else</p>
</div>
div.post {
    margin-bottom: 3em;
}

If you are using HTML5 then use <article> instead of <div class="post"> to denote individual posts.

As for grouping tags, this is currently not possible in plain HTML, you need to apply some preprocessing for that. The usual solution is to use a content management system which creates the final HTML based on your content and an HTML template.

Upvotes: 1

John Conde
John Conde

Reputation: 219814

You don't need the <br> tags because <hr> is a block level element and automatically creates a line break. If you're doing that to get some vertical space above and below thw <hr> why not just use CSS to give the <hr> some margin?

hr
{
    margin-bottom: 20px;
    margin-top: 20px;
}

Upvotes: 1

Related Questions