Should we try to use all H1 to H6 in a website? - css

Should we use all H1 to H6 in a website?
i use h1 to h2 usually. now how to judge and decide where to use H3 to h6.
should we use like this
h3 {display:inline}
<div id="content">
<h3> some text in bold:</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
<h3> some text in bold:</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
or this
span {font-weight:bold}
<div id="content">
<p><span> some text in bold:</span>
Lorem ipsum dolor sit amet,
consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua.
</p>
<p><span> some text in bold:</span>
Lorem ipsum dolor sit amet,
consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua.
</p>
</div>
to get result lke this
alt text http://easycaptures.com/fs/uploaded/226/1452064646.png
Both methods are W3C valid, with css i can achieve same look from both method so which is semantic and accessible?

If the text is functioning as a header level under the H2 level, it would be an H3. Rinse/repeat for H4 to H6.
XHTML is semantic -- use the tags based on what they mean. What they look like is your choice, including whether they are displayed as block elements or inline.

A heading is a title for a section of a page. It describes that section, in a few words.
There’s no simple rule to work out if a given bit of bold text in a document is best marked-up as a heading.
In the example you’ve given, it’s particularly hard to tell if the bold text should be a heading, because the text is meaningless placeholder text. “Semantic” just means “meaning”. The “most semantic” markup is the one that best communicates the meaning of the page. Because the placeholder text has no meaning, you can't choose how to mark it up.
One way to decide whether some text should be marked up as a heading is to imagine what the document would look like if the user could only see an outline of it, generated from its headings. E.g.
<h1>
<h2>
<h3>
<h3>
<h2>
<h3>
<h4>
<h2>
<h3>
Would the text make sense in the outline? Or is it not really a heading, but instead just in bold because the designer wanted to emphasise it?

When writing pages I try to think of it as writing a Book, if the content is related to the parent section in such a way to deserve its own section, then use H3, H4... otherwise you can use other html tags, such as a dd (Definition List) or ul (Unordered List).
Of course, if you are going for SEO, then always use your h1 and h2, for main content titles (or simply the information you want the user to find). And then, as previously stated before go for trying to make it feel like a book (publication).

You use them as you need them, just as you would with any other tag (outside of the obligatory tags: html, head, etc.) Use them when you need them, but use them properly.

You should note that search engines such as Google use header tags(H1) when processing pages for indexing and page rank etc.
See How Google is using HTML tags to enhance the search engine?

HTML is a markup language, which simplified means describing your content semantically. CSS is for styling your content, i.e. the visual part. Just like <p> means a block of text is a parapgraph <Hn> means a block of text is a heading.
Headings describe the structure of your document, a treelike data structure, if you will.
The Web Developer extension for Firefox has a nice feature that allows you to see your marked up document structure. You can find it under Information->Document outline.

From an accessibility standpoint don't use multiple levels of headings unless it makes sence for your content structure. For example the main document should have heading level one, main sections in the document should have heading level two, and subsections should have heading level three. Wikipedia does a good job of this, for an example see the following link that has both sections and subsections.
http://en.wikipedia.org/wiki/Database_normalization

If you intend for the content to be a subsection (i.e. a distinct separation, not merely a paragraph block) of the section you're in, use the next available heading level. Otherwise, just stick it in a paragraph. Unless absolutely necessary, avoid wrapping your elements in a div tag just for the sake of having a div tag. It's not semantic and may throw off search engine spiders.

Related

Can I set um a MINIMUM number of lines (forcing a line break in small texts) using only CSS?

I keep getting designs from agencies with texts breaking in different widths for the same templates, so I was wondering if there is a way using only CSS to force a text to break in at least N number of lines no matter it's size. Something similar to a added to the middle of the sentence, but without using br so it ajusts accordingly on multiple screens.
A text like "lorem ipsum dolor sit amet consectetur adipiscing elit" forced to use 2 lines would look like this (assuming the width available is much larger):
lorem ipsum dolor sit amet
consectetur adipiscing elit
And a text like "lorem ipsum" would look like this:
lorem
ipsum
Of course a single word would use only a single line, and large enough texts would use more than 2 lines.
I'm experienced enough to do this using JS and it feels like dirty work. I was wondering if I'm missing some CSS property like "minimum-lines".

Wrapping a column around a shorter column in Bootstrap 4

I am using Bootstrap 4. I have a simple two column layout. The right column has a table of contents, the left column has a lot of markup with paragraphs, lists, images, and so on. I would like the content of the left column to use the whole width (of both columns) where the table of contents (which takes less vertical space) ends.
Like wrapping around an image except this is wrapping around a <div> with lots of stuff inside.
Is this possible (whether or not you think its a good idea?)
this is what I would do: float (yes, float in Bootstrap-4) the div to the right side while having the col-6 class present there as well;
Is it a good idea? The customer is always right. Having said that, many people in Communications/Marketing departments have a history of working with print... so they may push for this to be implemented for a variety of reasons...
Look forward to your feedback and the 'real' answer like many professors reveal after a student gives it a shot :)
.myDiv {
border: 1px solid red;
float: right; margin-left:5px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<div class="container">
<div class="row">
<div class="col-12">
<div class="col-6 myDiv">
<h2> Right hand zone (6 col at the start) </h2>
I am using Bootstrap 4. I have a simple two column layout. The right column has a table of contents, the left column has a lot of markup with paragraphs, lists, images, and so on. I would like the content of the left column to use the whole width (of
both columns) where the table of contents (which takes less vertical space) ends. Like wrapping around an image except this is wrapping around a with lots of stuff inside. Is this possible (whether or not you think its a good idea?)</div>
<h1>Continued text (6 col at the start and then all width) </h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit... What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown
printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release
of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it? Where can I get some? There are many variations of passages of Lorem
Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything
embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined
with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris...</p>
<h3>continuing...</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...Where does it come from? Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the
undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance.
The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus
Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
<h3>continuing further...</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit... It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less
normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem
ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
</div>
</div>
</div>

How to use offset in twitter bottstrap grid layout

I am tying to apply an offset to a column in twitters bootstrap framework using this code
<div class="container">
<div class="row">
<div class="col-md-4 col-md-offset-4">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
</div>
</div>
Unfortunately the column is not getting affected by the offset class.
Every other class is working.
What am I doing wrong?
I am pretty sure that you just want to update your version of bootstrap to the latest version. I was able to view your code in an mvc project and it displayed right for me. Here is another question with references to the offset class and bootstrap versions: SO question.
I can't see any other reason why your code would not work unless you have another class in a css file that has an alternate definition for one of your class names.

Hetrogenous highlight in HTML 5

So I am trying to highlight some text in my html notes, but it fails if that highlight "region" has another tag in it see this.
I just want it to give pink bg to important text just like a real highlighter does, like so
I tried SPAN, MARK & DIV to achieve this, but all fails.
Note: I understand I can enclose important text in appropriate divs again & again but I am looking for some way that would accomplish real-ish highlighting in one tag
HTML noob, please warn before down-voting
this syntax is too bad you can't open a tag and close it inside another tag like so :
<p>
lorem ipsum sit <mark class="hetro"> amet dolor
</p>
<h2> a heading </h2>
<p>
lorem ipsum sit </mark> amet dolor
</p>
what you can do is applying this mark inside the other tag's too like the following :
<p>
lorem ipsum sit <mark class="hetro"> amet dolor</mark>
</p>
<h2> <mark class="hetro">a heading </mark></h2>
<p>
<mark class="hetro">lorem ipsum sit amet dolor</mark>
</p>
LIVE DEMO
according to Wikipedia :
"tag soup" refers to syntactically or structurally incorrect HTML
written for a web page. Because web browsers have historically treated
HTML syntax or structural errors leniently, there has been little
pressure for web developers to follow published standards, and
therefore there is a need for all browser implementations to be able
to treat what looks like HTML as "tag soup", accepting and correcting
for invalid syntax and structure.

cancelling text-align: justify; for certain parts of text

To prevent wrapping of a part of text, surrounding that part in a <span style="white-space: nowrap;"> can be used.
Given a block of justified text (text-align: justify), how do I cancel justification for a part of the text? I want to keep the whole text justified, but not allow to increase distance between two specific words.
Instead of even spacing in the second line like this:
Lorem ipsum dolor sit amet, consectetur |
adipiscing elit. Phasellus et |
ullamcorperenim sed velit fermentum. |
I want to keep the words "adipiscing elit" together, like this:
Lorem ipsum dolor sit amet, consectetur |
adipiscing elit. Phasellus et |
ullamcorperenim sed velit fermentum. |
Is this possible?
Options:
Use FOUR-PER-EM SPACE U+2005 instead of normal space, e.g. adipiscing elit. There is no guarantee that browsers treat it as non-stretchable space, but that’s what they actually do, and it’s a rather natural thing to do. After all, it is one of the fixed-width spaces. Drawback: typically fails on IE 6 (a small box is shown instead of a space), if the primary font of the text is not Arial Unicode MS or some other especially “rich” font.
Wrap the words inside some inline markup (typically span) and set text-justify: none and display: inline-block for it. Drawbacks: does not work old some old browsers, and forces the two words together (due to the latter declaration—and without it, this methods does not work on current browsers).
Use NO-BREAK SPACE instead of normal space. This used to work well, though with the drawback to forcing the two words together on the same line. But e.g. current Firefox treats no-break as stretchable, sadly enough.
Use a technique like the one in Web_Designer’s updated answer. I would suggest making the width em valued, to make it relate to the font size. The typical width of a space is 0.25em.
I wouldn't recommend using the html style attribute. If you use a class, then it's easier to make changes:
Wrap the two words "adipiscing elit." in a span with a class like this:
<span class="unjustify">adipiscing elit.</span>
And then in your CSS:
.unjustify {
word-spacing: 2px; //experiment with differen't values here.
}
Update:
After some testing the above solution doesn't seem to work. ...so I came up with the following (working) solution:
Wrap the space between your two words in a span with a class like this:
adipiscing<span class="unjustify"> </span>elit.
And then in your CSS:
.unjustify {
display: inline-block;
width: 6px;
}
One solution you should look into is to use one of several fixed-width Unicode space characters. See:
https://jkorpela.fi/chars/spaces.html
or
http://en.wikipedia.org/wiki/Space_(punctuation)
Example:
adipiscing elit.
However like Web_Designer's solution these will leave a space at the end of the line, if the line breaks there.

Resources